<template>
  <el-main style="padding: 10px">
    <el-card class="box-card" style="padding: 24px; margin-bottom: 10px">
      <div class="card-header is-justify-space-between is-align-center el-row--flex" style="margin: 16px 0px">
        <span class="condition-title el-col el-col-24">添加惩处</span>
      </div>
      <el-form ref="form" :model="form" label-width="100px" style="margin-top:80px;">
        <el-form-item label="成果类型">
          <el-select v-model="form.award_type" placeholder="请选择">
            <el-option
              v-for="item in form.options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="学号">
          <el-input v-model="form.stu_id" style="width: 140px" clearable />
        </el-form-item>

        <el-form-item label="相关属性">
          <el-input
            v-model="form.input"
            type="textarea"
            :rows="2"
            placeholder="请输入内容"
            style="width: 50%"
          />
        </el-form-item>

        <el-form-item label="日期">
          <el-date-picker
            v-model="form.value2"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          />
        </el-form-item>

        <el-form-item label="相关属性">
          <el-select v-model="form.value1" multiple placeholder="请选择">
            <el-option
              v-for="item in form.options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="证明材料">
          <el-upload
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            multiple
            :limit="3"
            :on-exceed="handleExceed"
            :file-list="form.fileList"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">上传提示</div>
          </el-upload>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即创建</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </el-main>

</template>

<script>
export default {
  data() {
    return {
      form: {
        options: [{
          value: '选项1',
          label: '处分一'
        }, {
          value: '选项2',
          label: '处分二'
        }],
        award_type: '',
        stu_id: '',
        input: '',
        value1: [],
        value2: [],
        fileList: []
      }
    }
  },
  methods: {
    onSubmit() {
      console.log('submit!')
    },
    handleRemove(file, fileList) {
    },
    handlePreview(file) {
      console.log(file)
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    }
  }
}
</script>

<style scoped>
.condition-title {
  color: #2b3b4e;
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
}
</style>
